<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>echarts测试</title>
</head>
<body>
<!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
<div id="bar" style="width: 600px;height:400px;"></div>
<div id="pie" style="width: 1000px;height:500px;"></div>
</body>
<script src="../js/echarts.common.min.js"></script>
<script>
    //柱状图
    // 基于准备好的dom，初始化echarts实例
    let barCharts=echarts.init(document.getElementById("bar"));

    // 指定图表的配置项和数据
    let barOption={
        title:{
            text:'Echarts Bar 测试'
        },
        tooltip:{},
        legend: {
            data:['销量']
        },
        xAxis:{
            data:["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
        },
        yAxis:{},
        series:[{
            name:'销量',
            type:'bar',
            data:[5, 20, 36, 10, 10, 20]
        }]
    };

    // 使用刚指定的配置项和数据显示图表。
    barCharts.setOption(barOption);

    //饼图
    let pieCharts=echarts.init(document.getElementById('pie'));
    let pieOption={
        title: {
            text: '同名数量统计',
            subtext: '纯属虚构',
            left: 'center'
        },
        tooltip: {
            trigger: 'item',
            formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
            type: 'scroll',
            orient: 'horizontal',
            //right: 10,
            //top: 20,
            bottom: 20
            //data: data.legendData

            //selected: data.selected
        },
        series: [
            {
                name: '姓名',
                type: 'pie',
                radius: '55%',
                center: ['30%', '50%'],
                data: [
                    {value: 1048, name: '搜索引擎'},
                    {value: 735, name: '直接访问'},
                    {value: 580, name: '邮件营销'},
                    {value: 484, name: '联盟广告'},
                    {value: 300, name: '视频广告'}
                ],
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            },
            {
                name: '姓名',
                type: 'pie',
                radius: '35%',
                center: ['70%', '50%'],
                data: [
                    {value: 2048, name: '搜索引擎'},
                    {value: 735, name: '直接访问'},
                    {value: 880, name: '邮件营销'},
                    {value: 284, name: '联盟广告'},
                    {value: 1300, name: '视频广告'}
                ],
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
    pieCharts.setOption(pieOption);
</script>
</html>